<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>news</title>
	<link rel="stylesheet" type="text/css" href="../easyui/1.5.3/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../css/wu.css" />
    <link rel="stylesheet" type="text/css" href="../css/icon.css" />
    <script type="text/javascript" src="../js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="../js/jquery.serializejson.min.js"></script>
    <script type="text/javascript" src="../easyui/1.5.3/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../easyui/1.5.3/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../public/xheditor/xheditor-1.2.2.min.js"></script>
</head>
<body>
	 <div class="easyui-layout" data-options="fit:true">
        
        <div data-options="region:'center',title:'Main Title',border:false,iconCls:'icon-ok'">
        
    	<form id="ff" class="easyui-form" method="post" data-options="novalidate:true">
            <div style="margin-bottom:20px;margin-top: 50px;">
                <input class="easyui-textbox" name="title" style="width:80%" data-options="label:'标题:',required:true">
            </div>
			<div style="margin-bottom:20px">
                <input class="easyui-textbox" name="author" style="width:80%" data-options="label:'作者:',required:true">
            </div>
			<div style="margin-bottom:20px">
                <input class="easyui-textbox" name="viceTitle" style="width:80%" data-options="label:'			副标题:',required:true">
            </div>
			<div style="margin-bottom:20px">
				<span style="margin-right: 45px;">正文：</span>
                <textarea class="textarea easyui-validatebox xheditor" name="content" style="width:80%;height:300px;" data-options="label:'',required:true"></textarea>
            </div>
            <div style="margin-bottom:20px"> 
                <!-- <input class="easyui-combobox" style="width:150px;" type="text" name="text" data-options="label:'分类:',required:true" id="text" > -->
                    <select id="text" class="easyui-combobox" name="text" style="width:200px;" data-options="label:'分类:',required:true">
                        <option>政治</option>
                        <option>文化</option>
                        <option>体育</option>
                        <option>娱乐</option>
                        <option>国外</option>
                        <option>国内</option>
                    </select>
            </div>
            
        </form>



        <div style="text-align: center;padding: 5px 0">
            <a href="javascript:;void(0)" class="easyui-linkbutton" onclick="newsAddAction()">submit</a>
            <a href="javascript:;void(0)" class="easyui-linkbutton" onclick="clearForm()" >clear</a>
        </div>
    </div>

    <script type="text/javascript">

        function newsAddAction(){
         $('#ff').form('submit',{
            onSubmit:function(){
                if ($(this).form('enableValidation').form('validate')){
                    $.ajax({
                        type:"post",
                        url:"http://localhost:3000/news/data",
                        data:$("#ff").serializeJSON()
                    }).then(function(res){
                        console.log(res)
                    });
                }else{
                    alert('no')
                }
            }
        });
         addTab('分类管理','cate/cate.html',null,1);


    }
       
        function clearForm(){
            $('#ff').form('clear');
            $('.xheditor').form('clear');
        }
        
        function addTab(title, href, iconCls, iframe){
            var tabPanel = window.parent.$('#wu-tabs');
            if(!tabPanel.tabs('exists',title)){
                var content = '<iframe scrolling="auto" frameborder="0"  src="'+ href +'" style="width:100%;height:100%;"></iframe>';
                if(iframe){
                    tabPanel.tabs('add',{
                        title:title,
                        content:content,
                        iconCls:iconCls,
                        fit:true,
                        cls:'pd3',
                        closable:true
                    });
                }
                else{
                    tabPanel.tabs('add',{
                        title:title,
                        href:href,
                        iconCls:iconCls,
                        fit:true,
                        cls:'pd3',
                        closable:true
                    });
                }
            }
            else
            {
                tabPanel.tabs('select',title);
            }
        }
    </script>
</body>
</html>